package io.github.shang11925.sbvuewelearn.service.impl;

import io.github.shang11925.sbvuewelearn.dao.TextImagesRepository;
import io.github.shang11925.sbvuewelearn.dto.TextImagesDTO;
import io.github.shang11925.sbvuewelearn.entity.TextImages;
import io.github.shang11925.sbvuewelearn.service.TextImagesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TextImagesServiceImpl implements TextImagesService {
    @Autowired
    TextImagesRepository textImagesRepository;

    @Override
    public List<TextImages> findBySectionId(Long sectionId) {
        return textImagesRepository.findBySectionId(sectionId);
    }

    @Override
    public void add(TextImagesDTO textImagesDTO) {
        TextImages textImages = new TextImages();
        textImages.setImageUrl(textImagesDTO.getImageUrl());
        textImages.setDescription(textImagesDTO.getDescription());

        textImagesRepository.save(textImages);
    }
}
